package com.wyc.apidriver.controller;

import com.wyc.apidriver.service.ApiOrderService;
import com.wyc.internalCommon.request.OrderInfo;
import com.wyc.internalCommon.result.ApiResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
public class OrderController {

    @Autowired
    private ApiOrderService orderService;

    /**
     * 司机出发去接乘客
     * @param orderInfo
     * @return
     */
    @PostMapping("/to-pick-up-passenger")
    public ApiResult toPickUpPassenger(@RequestBody OrderInfo orderInfo){
        return orderService.toPickUpPassenger(orderInfo);
    }

    /**
     * 司机到达上车地点
     * @param id
     * @return
     */
    @GetMapping("/driver-arrived-departure")
    public ApiResult driverArrivedDeparture(@RequestParam Long id){
        return orderService.driverArrivedDeparture(id);
    }

    /**
     * 司机接到乘客
     * @param orderInfo
     * @return
     */
    @PostMapping("/pick-up-passenger")
    public ApiResult pickUpPassenger(@RequestBody OrderInfo orderInfo){
        return orderService.pickUpPassenger(orderInfo);
    }

    /**
     * 乘客下车，行程结束
     * @param orderInfo
     * @return
     */
    @PostMapping("/passenger-getoff")
    public ApiResult passengerGetoff(@RequestBody OrderInfo orderInfo){
        return orderService.passengerGetoff(orderInfo);
    }

    /**
     * 取消订单
     * @param orderId
     * @param identity 取消人的身份标识（1.乘客 2.司机3.平台）
     * @return
     */
    @PostMapping("/order-cancel")
    public ApiResult cancelOrder(@RequestParam("orderId") Long orderId, @RequestParam("identity") String identity){
        return orderService.cancelOrder(orderId,identity);
    }

}
